package com.lc.hot100.lc283;

public class Main {

	
}

class Solution1 {
	public void swap(int[] nums, int i, int j) {
		int t = nums[i];
		nums[i] = nums[j];
		nums[j] = t;
	}
	
    public void moveZeroes(int[] nums) {
    	int n = nums.length;
        int i = 0, j = 0;
        
        
        while(i < n) {
        	
        	while(i < n && nums[i] != 0) {
        		i ++;
        	}
        	if (i >= n) {
        		break;
        	}
        	j = i + 1;
        	while(j < n && nums[j] == 0) {
        		j ++;
        	}
        	if (j >= n) {
        		break;
        	}
        	
        	swap(nums, i, j);
        	
        }
    }
}

class Solution {
	public void swap(int[] nums, int i, int j) {
		int t = nums[i];
		nums[i] = nums[j];
		nums[j] = t;
	}
	
    public void moveZeroes(int[] nums) {
        
    	int n = nums.length;
    	int i = 0, j = 0;
    	while(j < n) {
    		if (nums[j] != 0) {
    			swap(nums, i, j);
    			i ++;
    		}
    		j ++;
    	}
    }
}
